package models;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import org.hibernate.validator.constraints.NotEmpty;

import play.db.ebean.Model;

@Entity
public class Turma extends Model{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	public long id;
	
	@NotEmpty
	public String codigo;
	
	public String descricao;
	
	public String horario;
	
	public String local;
	
	public String semestre;
	
	@Min(0)
	public int numVagas;
	
	public boolean status;
	
	@Min(0)
	@Max(100)
	public int mediaAprovacao;

	@Temporal(TemporalType.DATE)
	public Date dtMatriculaInicio;
	
	@Temporal(TemporalType.DATE)
	public Date dtMatriculaFim;
	
	@Temporal(TemporalType.DATE)
	public Date dtAulaInicio;
	
	@Temporal(TemporalType.DATE)
	public Date dtAulaFim;
		
	@Temporal(TemporalType.DATE)
	public Date dtCadastro;
	
	// ------------------relacionamentos---------------------//
	@ManyToOne
	public Disciplina disciplina;
	
	@ManyToOne
	public Usuario professor;
	
	@OneToMany(mappedBy="turma", fetch=FetchType.LAZY)
	public List<TopicoDiscussao> topicosDiscussoes = new ArrayList<TopicoDiscussao>();
	
	@OneToMany(mappedBy="turma", fetch=FetchType.LAZY)
	public List<Atividade> atividades = new ArrayList<Atividade>();
	
	@OneToMany(mappedBy="turma", fetch=FetchType.LAZY)
	public List<Conteudo> conteudos = new ArrayList<Conteudo>();
	
	@OneToMany(mappedBy="turma", fetch=FetchType.LAZY)
	public List<Prova> provas = new ArrayList<Prova>();
}
